using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class admisionMap : EntityTypeConfiguration<admision>
    {
        public admisionMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.ID)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.CUST_ID)
                .IsRequired()
                .HasMaxLength(6);

            this.Property(t => t.REF_PHY)
                .HasMaxLength(30);

            this.Property(t => t.LIC_NO)
                .HasMaxLength(20);

            this.Property(t => t.INS_PART1)
                .HasMaxLength(6);

            this.Property(t => t.INS_PART2)
                .HasMaxLength(6);

            this.Property(t => t.BED_NO)
                .HasMaxLength(4);

            this.Property(t => t.PRICE_CODE)
                .HasMaxLength(1);

            this.Property(t => t.ATTEND_PHY)
                .HasMaxLength(6);

            this.Property(t => t.Visa_)
                .HasMaxLength(20);

            this.Property(t => t.Visa_2)
                .HasMaxLength(20);

            this.Property(t => t.TIME)
                .HasMaxLength(10);

            this.Property(t => t.ROOMNUM)
                .HasMaxLength(10);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            this.Property(t => t.DIAG_DESC)
                .HasMaxLength(100);

            this.Property(t => t.DIAG_NOTE)
                .HasMaxLength(500);

            this.Property(t => t.CardNumber)
                .HasMaxLength(50);

            this.Property(t => t.CardNumber2)
                .HasMaxLength(50);

            this.Property(t => t.self_insured)
                .HasMaxLength(50);

            this.Property(t => t.DiagNo)
                .HasMaxLength(50);

            this.Property(t => t.Note)
                .HasMaxLength(200);

            this.Property(t => t.Soap_)
                .HasMaxLength(50);

            this.Property(t => t.admstatus)
                .HasMaxLength(50);

            this.Property(t => t.Employer)
                .HasMaxLength(50);

            this.Property(t => t.EmployerNb)
                .HasMaxLength(20);

            this.Property(t => t.TrackNumber)
                .HasMaxLength(20);

            this.Property(t => t.cid)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            this.Property(t => t.UID)
                .HasMaxLength(50);

            this.Property(t => t.Location)
                .HasMaxLength(50);

            this.Property(t => t.AD_status)
                .IsFixedLength()
                .HasMaxLength(1);

            this.Property(t => t.IntRefPhys)
                .HasMaxLength(6);

            this.Property(t => t.ADM_NUMBER)
                .HasMaxLength(30);

            this.Property(t => t.ADM_TYPE)
                .HasMaxLength(3);

            this.Property(t => t.ADM_MR_TO)
                .HasMaxLength(50);

            this.Property(t => t.ADM_MR_NOTE)
                .HasMaxLength(500);

            this.Property(t => t.ADM_MR_REQ_NB)
                .HasMaxLength(20);

            this.Property(t => t.ADM_MR_PHYS2)
                .HasMaxLength(6);

            // Table & Column Mappings
            this.ToTable("admision");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.CUST_ID).HasColumnName("CUST_ID");
            this.Property(t => t.ENTRY_DATE).HasColumnName("ENTRY_DATE");
            this.Property(t => t.DISCH_DATE).HasColumnName("DISCH_DATE");
            this.Property(t => t.REF_PHY_ID).HasColumnName("REF_PHY_ID");
            this.Property(t => t.REF_PHY).HasColumnName("REF_PHY");
            this.Property(t => t.LIC_NO).HasColumnName("LIC_NO");
            this.Property(t => t.MAIN_COMP).HasColumnName("MAIN_COMP");
            this.Property(t => t.ENTRY_TYPE).HasColumnName("ENTRY_TYPE");
            this.Property(t => t.ENTRY_CLAS).HasColumnName("ENTRY_CLAS");
            this.Property(t => t.INS_PART1).HasColumnName("INS_PART1");
            this.Property(t => t.INS_PART2).HasColumnName("INS_PART2");
            this.Property(t => t.BED_NO).HasColumnName("BED_NO");
            this.Property(t => t.WEQW).HasColumnName("WEQW");
            this.Property(t => t.PRICE_CODE).HasColumnName("PRICE_CODE");
            this.Property(t => t.ATTEND_PHY).HasColumnName("ATTEND_PHY");
            this.Property(t => t.ADMITTED).HasColumnName("ADMITTED");
            this.Property(t => t.OUTPATIENT).HasColumnName("OUTPATIENT");
            this.Property(t => t.PCODE).HasColumnName("PCODE");
            this.Property(t => t.Visa_).HasColumnName("Visa#");
            this.Property(t => t.Visa_2).HasColumnName("Visa#2");
            this.Property(t => t.TIME).HasColumnName("TIME");
            this.Property(t => t.ROOMNUM).HasColumnName("ROOMNUM");
            this.Property(t => t.FACILITYID).HasColumnName("FACILITYID");
            this.Property(t => t.BOOKINGTYPE).HasColumnName("BOOKINGTYPE");
            this.Property(t => t.DURATION).HasColumnName("DURATION");
            this.Property(t => t.FACILITYTYPEID).HasColumnName("FACILITYTYPEID");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.VISADATE).HasColumnName("VISADATE");
            this.Property(t => t.VisaDate2).HasColumnName("VisaDate2");
            this.Property(t => t.GARMONTHLYSERIAL).HasColumnName("GARMONTHLYSERIAL");
            this.Property(t => t.FACILITYWARD).HasColumnName("FACILITYWARD");
            this.Property(t => t.DIAG_DESC).HasColumnName("DIAG_DESC");
            this.Property(t => t.DIAG_NOTE).HasColumnName("DIAG_NOTE");
            this.Property(t => t.ContractGuar1).HasColumnName("ContractGuar1");
            this.Property(t => t.ContractGuar2).HasColumnName("ContractGuar2");
            this.Property(t => t.CardNumber).HasColumnName("CardNumber");
            this.Property(t => t.CardNumber2).HasColumnName("CardNumber2");
            this.Property(t => t.StartDate).HasColumnName("StartDate");
            this.Property(t => t.StartDate2).HasColumnName("StartDate2");
            this.Property(t => t.EndDate).HasColumnName("EndDate");
            this.Property(t => t.EndDate2).HasColumnName("EndDate2");
            this.Property(t => t.classId).HasColumnName("classId");
            this.Property(t => t.ClassGuar1).HasColumnName("ClassGuar1");
            this.Property(t => t.ClassGuar2).HasColumnName("ClassGuar2");
            this.Property(t => t.self_insured).HasColumnName("self_insured");
            this.Property(t => t.relation_to_insured).HasColumnName("relation_to_insured");
            this.Property(t => t.DiagNo).HasColumnName("DiagNo");
            this.Property(t => t.lblNum).HasColumnName("lblNum");
            this.Property(t => t.DiagnosisId).HasColumnName("DiagnosisId");
            this.Property(t => t.Note).HasColumnName("Note");
            this.Property(t => t.Soap_).HasColumnName("Soap#");
            this.Property(t => t.Current).HasColumnName("Current");
            this.Property(t => t.Discharge_Type).HasColumnName("Discharge_Type");
            this.Property(t => t.admstatus).HasColumnName("admstatus");
            this.Property(t => t.Employer).HasColumnName("Employer");
            this.Property(t => t.EmployerNb).HasColumnName("EmployerNb");
            this.Property(t => t.VisaFlag).HasColumnName("VisaFlag");
            this.Property(t => t.VisaFlag2).HasColumnName("VisaFlag2");
            this.Property(t => t.VisaEndDate).HasColumnName("VisaEndDate");
            this.Property(t => t.VisaEndDate2).HasColumnName("VisaEndDate2");
            this.Property(t => t.TrackIncNumber).HasColumnName("TrackIncNumber");
            this.Property(t => t.TrackNumber).HasColumnName("TrackNumber");
            this.Property(t => t.cid).HasColumnName("cid");
            this.Property(t => t.CSTCTRID).HasColumnName("CSTCTRID");
            this.Property(t => t.Hasinsurance).HasColumnName("Hasinsurance");
            this.Property(t => t.edittracknb).HasColumnName("edittracknb");
            this.Property(t => t.UID).HasColumnName("UID");
            this.Property(t => t.Location).HasColumnName("Location");
            this.Property(t => t.AD_status).HasColumnName("AD_status");
            this.Property(t => t.IntRefPhys).HasColumnName("IntRefPhys");
            this.Property(t => t.ADM_OutCurrent).HasColumnName("ADM_OutCurrent");
            this.Property(t => t.ADM_OutDischargedAt).HasColumnName("ADM_OutDischargedAt");
            this.Property(t => t.ADM_ETSF_FROM).HasColumnName("ADM_ETSF_FROM");
            this.Property(t => t.ADM_ITSF_TO_WARD).HasColumnName("ADM_ITSF_TO_WARD");
            this.Property(t => t.ADM_ITSF_TO_FAC).HasColumnName("ADM_ITSF_TO_FAC");
            this.Property(t => t.ADM_EMG_TRANSPORT).HasColumnName("ADM_EMG_TRANSPORT");
            this.Property(t => t.ADM_EMG_STATUS).HasColumnName("ADM_EMG_STATUS");
            this.Property(t => t.ADM_EMG_LOCATION).HasColumnName("ADM_EMG_LOCATION");
            this.Property(t => t.ADM_ITSF_DATE).HasColumnName("ADM_ITSF_DATE");
            this.Property(t => t.ADM_NUMBER).HasColumnName("ADM_NUMBER");
            this.Property(t => t.ADM_TYPE).HasColumnName("ADM_TYPE");
            this.Property(t => t.ADM_CreatedBy).HasColumnName("ADM_CreatedBy");
            this.Property(t => t.ADM_CreatedON).HasColumnName("ADM_CreatedON");
            this.Property(t => t.ADM_MR_TO).HasColumnName("ADM_MR_TO");
            this.Property(t => t.ADM_MR_NOTE).HasColumnName("ADM_MR_NOTE");
            this.Property(t => t.ADM_MR_REQ_NB).HasColumnName("ADM_MR_REQ_NB");
            this.Property(t => t.ADM_MR_REQ_DATE).HasColumnName("ADM_MR_REQ_DATE");
            this.Property(t => t.ADM_MR_PHYS2).HasColumnName("ADM_MR_PHYS2");

            // Relationships
            this.HasOptional(t => t.ADM_EMGLOC)
                .WithMany(t => t.admisions)
                .HasForeignKey(d => d.ADM_EMG_LOCATION);
            this.HasOptional(t => t.ADM_EMGSTATUS)
                .WithMany(t => t.admisions)
                .HasForeignKey(d => d.ADM_EMG_STATUS);
            this.HasOptional(t => t.ADM_EMGTRANS)
                .WithMany(t => t.admisions)
                .HasForeignKey(d => d.ADM_EMG_TRANSPORT);
            this.HasOptional(t => t.adm_ent)
                .WithMany(t => t.admisions)
                .HasForeignKey(d => d.ENTRY_TYPE);
            this.HasOptional(t => t.ADM_TSFPARTY)
                .WithMany(t => t.admisions)
                .HasForeignKey(d => d.ADM_ETSF_FROM);
            this.HasOptional(t => t.CoverageClass)
                .WithMany(t => t.admisions)
                .HasForeignKey(d => d.classId);
            this.HasOptional(t => t.CoverageClass1)
                .WithMany(t => t.admisions1)
                .HasForeignKey(d => d.ClassGuar1);
            this.HasOptional(t => t.CoverageClass2)
                .WithMany(t => t.admisions2)
                .HasForeignKey(d => d.ClassGuar2);
            this.HasRequired(t => t.Cust)
                .WithMany(t => t.admisions)
                .HasForeignKey(d => d.CUST_ID);
            this.HasOptional(t => t.Cust1)
                .WithMany(t => t.admisions1)
                .HasForeignKey(d => d.INS_PART1);
            this.HasOptional(t => t.Cust2)
                .WithMany(t => t.admisions2)
                .HasForeignKey(d => d.INS_PART2);
            this.HasOptional(t => t.DischargeType)
                .WithMany(t => t.admisions)
                .HasForeignKey(d => d.Discharge_Type);
            this.HasOptional(t => t.GuarantorContract)
                .WithMany(t => t.admisions)
                .HasForeignKey(d => d.ContractGuar1);
            this.HasOptional(t => t.GuarantorContract1)
                .WithMany(t => t.admisions1)
                .HasForeignKey(d => d.ContractGuar2);
            this.HasRequired(t => t.PriceLst)
                .WithMany(t => t.admisions)
                .HasForeignKey(d => d.PCODE);
            this.HasOptional(t => t.Ward)
                .WithMany(t => t.admisions)
                .HasForeignKey(d => d.FACILITYWARD);
            this.HasOptional(t => t.Name)
                .WithMany(t => t.admisions)
                .HasForeignKey(d => d.ADM_CreatedBy);

        }
    }
}
